package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wnhz.work.yz.R;
import com.wnhz.work.yz.bean.BathItemBean;
import com.wnhz.work.yz.bean.BathroomDetail2Bean;
import com.wnhz.work.yz.bean.ParamChildBean;
import com.wnhz.work.yz.view.NoScrollListView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by admin on 2016/12/22.
 */
public class ParameterAdapter2 extends BaseAdapter {
    private Context context;
    private List<BathroomDetail2Bean.ParamEntity.DataEntity> dataList = new ArrayList<>();
    private List<BathItemBean> data = new ArrayList<>();
    private ParamItemAdapter mAdapter;

    public ParameterAdapter2(Context context, List<BathroomDetail2Bean.ParamEntity.DataEntity> dataList) {
        this.context = context;
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();

    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ParameterViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ParameterViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.parameter_item, null);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_all_number = (TextView) convertView.findViewById(R.id.tv_all_number);
            viewHolder.my_listView = (NoScrollListView) convertView.findViewById(R.id.my_listView);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ParameterViewHolder) convertView.getTag();
        }
        Log.e("---",dataList.get(position).getCate_name()+"2");
        viewHolder.tv_title.setText(dataList.get(position).getCate_name());
        viewHolder.tv_all_number.setText("共" + dataList.get(position).getCount() + "件");

        data = dataList.get(position).getData();
        mAdapter = new ParamItemAdapter(context, data);
        viewHolder.my_listView.setAdapter(mAdapter);
        return convertView;
    }

    class ParameterViewHolder {
        TextView tv_all_number;
        NoScrollListView my_listView;
        TextView tv_title;

    }
}
